package com.mz.ozy.mvp.model;

import android.content.Context;
import android.text.TextUtils;

import com.mz.ozy.constants.Constants;
import com.mz.ozy.net.RetrofitUtils;
import com.mz.ozy.utils.JsonUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.function.DoubleUnaryOperator;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class DynamicsDetailModel {

    public Observable<ResponseBody> queryDynamicsDetail(Context context, int did) {
        Map<String, String> map = new HashMap<>();
        map.put("did", String.valueOf(did));
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10164, JsonUtils.requestJsonDate(map), Constants.tokenId);
    }

    public Observable<ResponseBody> commentDynamics(Context context, String cid, String pid, String uuid, String content) {
        Map<String, String> map = new HashMap<>();
        map.put("cid", cid);
        if (!TextUtils.isEmpty(pid)) {
            map.put("pid", pid);
        }
        if (!TextUtils.isEmpty(uuid)) {
            map.put("uuid", uuid);
        }
        map.put("content", content);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10158, JsonUtils.requestJsonDate(map), Constants.tokenId);
    }

    public Observable<ResponseBody> commentDynamics(Context context, int type, String cid, String pid, String uuid, String content) {
        Map<String, String> map = new HashMap<>();
        map.put("type", String.valueOf(type));
        map.put("cid", cid);
        if (!TextUtils.isEmpty(pid)) {
            map.put("pid", pid);
        }
        if (!TextUtils.isEmpty(uuid)) {
            map.put("uuid", uuid);
        }
        map.put("content", content);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10158, JsonUtils.requestJsonDate(map), Constants.tokenId);
    }

    public Observable<ResponseBody> deleteDynamics(Context context, int id) {
        Map<String, String> map = new HashMap<>();
        map.put("did", String.valueOf(id));
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10163, JsonUtils.requestJsonDate(map), Constants.tokenId);
    }
}
